package com.example.springfunction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@RestController
public class RestTemplateController {
    @Autowired
    private  ConfigDemoBean  configDemoBean;

    @Autowired
    private RestTemplate restTemplate;


    @GetMapping("/stock")
    public  Object stocks(){
        System.out.println(configDemoBean.getName("李瑞"));

        Map<String,Object> mp =new HashMap<>();
        mp.put("api_name","daily");
        mp.put("token","531f7eda35d265a43c7091a5971802aab320a80c16afb6e7164c595a");
        Map<String,String> mp2 =new HashMap<>();
        mp2.put("ts_code","000002.SZ");
        mp2.put("start_date","19980101");
        mp2.put("end_date","20210903");
        // mp2.put();
        mp.put("params",mp2);

        // mp.put("fields","ts_code,name,area,industry,list_date");
        mp.put("Content-type","application/json;charset=utf8");
        Object responseVo = restTemplate.postForObject("http://api.waditu.com", mp, Object.class);
        //System.out.println(responseVo.getString("data"));
       // System.out.println(responseVo);
        return responseVo;//.getString("data");

    }

}